package au.com.bus4u.controller;

import com.alibaba.fastjson.JSON;
import com.sun.xml.internal.ws.api.policy.SourceModel;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

/**
 * 404错误页面
 */
//@RequestMapping("")
//@Controller
public class CustomErrorController implements ErrorController {

    private static final String ERROR_PATH = "/error";

    @GetMapping(ERROR_PATH)
    public ModelAndView toError()throws Exception{
//        System.err.println("CustomErrorController.toError");
        ModelAndView mv = new ModelAndView();
        mv.setViewName("/error.html");//如果错误页面文件名就是/error.html,可无需添加此控制层类，会自动跳转到/error.html
        return mv;
    }


    @Override
    public String getErrorPath() {
        return ERROR_PATH;
    }

}
